home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Languages
/
Yerk 3.6.7
/
yerk 367
/
tool+
/
savedlg
< prev
next >
Wrap
Text File
|
1994-10-10
|
5KB
|
140 lines
\ Dialog subclass that saves an ascii representation of its data. Data may
\ be changed
\ 11.26.90 rfl added clear: parms to release: An error may occur if the
\ image is saved with parms. But fixed with new: sarray clearing size.
\ 11.28.90 rfl added dialog1 class to allow enabling etc. with controls
\ 12.13.91 rfl SP added alive: and close: to dialog1
\ 3.3.92 rfl changed string 161 to 186 for not finding STRG resource
\ 5.13/93 rfl no longer detach resource in grab; also, getnew: savedlg reads
\ in sarraystrg..don't have to grab at beginning of program
\ 3.15.94 rfl added clear: size for release:
\ 9.25.94 rfl removed close: dialog1 since it was the same as close: dialog
\ 10.10.94 rfl added txtTrue txtFalse
:CLASS dialog1 <super dialog
:M alive: ( -- b) get: dialPtr 0 <> ;M
:M hiliteCtl: ( n item --) handle: self swap makeint call hiliteControl ;M
:M drawItem: ( item --) dup getText: self rot putText: self ;M
:M dim: { n item -- } item handle: self drop
get: itemType 4 and \ is it a control?
IF n item hiliteCtl: self THEN \ standard disable
get: itemType 16 and
IF -3 -3 inset: temprect THEN \ is it editable text?
n 0<
IF 3 -> n \ also grey out item rectangle
set: self w 11 call penMode n syspat +base call penpat
paint: temprect call penNormal
ELSE item drawItem: self \ redraw original item
THEN ;M
:M enable: ( item --) 0 swap dim: self ;M
:M disable: ( item --) -1 swap dim: self ;M
:M hideItem: ( item --) get: dialPtr swap makeint call hideDItem ;M
:M showItem: ( item --) get: dialPtr swap makeInt call showDItem ;M
;CLASS
\ uses Pstring format (text with byte at front showing length of text)
\ same as sarray, but can be read from resource. Use STG# resource, with the first element
\ bogus. The number of elements of the STG# resource should equal the number of elements
\ of the savedlg object
:CLASS sarrayStrg <super sarray
int resID
int keepAsRsrc \ true if want to save the info in rsrc file
:M putResID: put: resID ;M
:M SaveAsRsrc: true put: keepAsRsrc ;M
:M dontSaveAsRsrc: clear: keepAsRsrc ;M
:M getnew: ( --)
get: resID 'type STG# (getres) m! m@ 0=
IF new: self
ELSE get: self scount put: size
THEN ;M
:M save: get: keepAsRsrc IF m@ call changedResource m@ call writeResource THEN ;M
:M release: m@ call releaseResource 0 m! clear: size ;M
;CLASS
:CLASS SaveDlg <super dialog1
sarrayStrg parms
:M putResID: dup putResID: super putResID: parms ;M
\ doesn't save useritems, since methods are unknown...just adds place holder
:M save: clear: parms 0 0 add: parms limit 1
DO i handle: self drop get: itemType dup 4 and \ 4=ctrlItem
IF i get: self bin>asc add: parms drop
ELSE $ 18 and \ $10 or $8=text item
IF i getText: self add: parms
ELSE 0 0 add: parms \ any other item type, fake
THEN
THEN
LOOP
save: parms ;M
\ doesn't handle a user item, since method of fill unknown
:M fill: limit: parms -dup
IF limit: self <> classErr" 186
limit 1
DO i handle: self drop get: itemType dup 4 and
IF i at: parms asc>bin i put: self drop
ELSE $ 18 and
IF i at: parms i putText: self THEN
THEN
LOOP
THEN ;M
:M getNew: getNew: super valid: parms not IF getNew: parms THEN fill: self ;M
:M new: new: parms ;M
\ grab a STG# resource and fill parms with it. Use in place of new.
\ parms id is same as dialog
:M grab: ( --) get: resID putResID: parms getnew: parms ;M
:M getParms: get: parms ;M
:M fillParms: ( anotherParm --) put: parms ;M
\ fill an empty sarray (not new:) with IVARS of pars
:M =: { mySarray -- } addr: parms mySarray length: mySarray cmove ;M
:M atParm: ( ind -- addr len) at: parms ;M
:M toParm: ( addr len ind --) to: parms ;M
:M print: print: parms ;M
:M closeSave: save: self close: self ;M
:M release: release: parms clear: parms ;M
:M lock: lock: parms ;M
:M unlock: unlock: parms ;M
:M saveAsRsrc: saveAsRsrc: parms ;M
:M dontSaveAsRsrc: dontSaveAsRsrc: parms ;M
\ for saving and restoring parameters to disk
:M write: size: parms sp@ 4 write: topfile 2drop
lock: parms get: parms write: topfile drop unlock: parms ;M
:M read: buf255 4 read: topfile drop
buf255 @ setsize: parmstr topfile size: parmstr read: parmstr drop
lock: parmstr get: parmstr put: parms unlock: parmstr ;M
;CLASS
: getter save: caller closer ;
\ ascii string true...use with atParm: which returns a " 1" or " 0"
: s1= " 1" s= ;
\ other useful words
: txtTrue ( addr len -- b) drop c@ ascii 1 = ;
: txtFalse ( addr len -- b) txtTrue not ;